从文件中读取整数并求和，直到文件结尾为止：

```c
#include <stdio.h>

int main()
{
    FILE *fp = fopen("input.txt", "r");
    if (fp == NULL)
    {
        printf("文件打开失败！\n");
        return -1;
    }

    int sum = 0;
    int num;
    while (!feof(fp)) // 当没有到达文件结尾时继续读取
    {
        if (fscanf(fp, "%d", &num) == 1)
        {
            sum += num;
        }
    }
    printf("和为：%d\n", sum);

    fclose(fp);
    return 0;
}

```
//